﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DataExtractionLanguage
{
    public static class Extensions
    {
        public static bool IsProperty(this TokenTypeEnum token)
        {
            return token.In(TokenTypeEnum.Text, TokenTypeEnum.GetAttribute, TokenTypeEnum.CountOf, TokenTypeEnum.ChildCount);
        }

        public static bool IsFunction(this TokenTypeEnum token)
        {
            return token.In(TokenTypeEnum.SubString, TokenTypeEnum.Length, TokenTypeEnum.Like, TokenTypeEnum.IndexOf);
        }
        public static bool IsJoinType(this TokenTypeEnum token)
        {
            return token.In(TokenTypeEnum.Inner, TokenTypeEnum.Left, TokenTypeEnum.Right);
        }

        public static bool In(this TokenTypeEnum token, params TokenTypeEnum[] tokens)
        {
            foreach (TokenTypeEnum item in tokens)
                if (item == token)
                    return true;
            return false;
        }
    }
}
